#ifndef __AUDIO_IN_AGORA_H__
#define __AUDIO_IN_AGORA_H__


#include "IAudioIn.h"
#include "IBuffer.h"
#include <vector>
#include "al/al.h"
#include "al/alc.h"
#include "IMutex.h"


class AudioIn : public IAudioIn
{
public:
	AudioIn(IBuffer*, unsigned int ALBufferSize);
	~AudioIn();
	char **DetectDevice(void);
	void SelectInDevice(char *, unsigned short frequence, char format);
	void SelectInDevice(int, unsigned short frequence, char format);
	void AutoSelectInDevice(unsigned short frequence, char format);
	IBuffer *GetBuffer();
	unsigned short GetFrequence();
	char GetFormat();
	void Start(void);
	void Stop(void);
private:
	static void runIn(AudioIn* audioIn);
	IMutex			*_mutex;
	char			*_deviceList;
	char			**_deviceTable;
	ALCdevice		*_currentDevice;
	char			*_samples;
	unsigned int	_alBufferSize;
	int	_alMaxSample;
	unsigned int	_sampleSize;
	unsigned short	_freq;
	char			_format;
	bool			_inRun;
	bool			_isRunning;
	int				_sleepReactivity;
	IBuffer			*_buf;
};

#endif
